import { BasicUiAction } from '../../engine/uiAction/basicUiAction.js';
import { InventoryUiAction } from '../../engine/uiAction/inventoryUiAction.js';
import { EnterpriseMgtUiAction } from '../../engine/uiAction/enterpriseMgtUiAction.js';
import { EmployeeMgrPageMode } from '../../engine/enterpriseMgt/employee.js';
import { Definition } from '../../engine/common/definition.js';
import { DocType } from '../../engine/common/docDefinition.js';


export class uiNavigation {

    /**
 * Show order detail page based on document type and order ID
 * @param {Object} router - Vue router instance
 * @param {DocType} type - Document type
 * @param {string} orderId - Order ID
 */
    static showOrderDetail(router, type, orderId) {
        switch (type.code) {
            /// 0 待出库单
            case DocType.DCKD.code:
            /// 1 待入库单
            case DocType.DRKD.code:
              
                break;

            /// 2 出库单
            case DocType.CKD.code:
              
                break;

            /// 3 入库单
            case DocType.RKD.code:
             
                break;

            /// 4 销售单
            case DocType.XSD.code:
               //uiNavigation.showSalesDetailPage(router,{id: orderId});
               uiNavigation.showMetalSalesDetailPage(router,{id: orderId});
                break;

            /// 5 采购单
            case DocType.CGD.code:
               uiNavigation.showMetalPurchaseDetailPage(router,{id: orderId});
                break;

            /// 6 应付款单
            case DocType.YFKD.code:
              
                break;

            /// 7 付款单
            case DocType.FKD.code:
             
                break;

            /// 8 应收款单
            case DocType.YSKD.code:
            
                break;

            /// 9 收款单
            case DocType.SKD.code:
             
                break;

            /// 10 销售退货单
            case DocType.XSTHD.code:
               
                break;

            /// 11 采购退货单
            case DocType.CGTHD.code:
            
                break;

            /// 12 预收款单 未使用
            case DocType.PreSKD.code:
                // Not implemented
                break;

            /// 13 预付款单 未使用
            case DocType.PreFKD.code:
                // Not implemented
                break;

            /// 直接 14（资金）付款单
            case DocType.ZFKD.code:
           
                break;

            /// 15 直接（资金）收款单
            case DocType.ZSKD.code:
              
                break;

            /// 盘点单 16
            case DocType.PDD.code:
             
                break;

            /// 调拨单 17
            case DocType.DBD.code:
             
                break;

            /// 应收单 18 未使用
            case DocType.YSD_TASK.code:
                // Not implemented
                break;

            /// 应付单 19 未使用
            case DocType.YFD_TASK.code:
                // Not implemented
                break;

            /// 成本调整单 20 (暂时未使用)
            case DocType.COST_ADJ.code:
                // Not implemented
                break;

            /// 未知
            case DocType.Unknown.code:
            default:
                // Handle unknown or unsupported document types
                console.warn('Unsupported document type:', type);
                break;
        }
    }
    // 页面跳转方法直接在每个函数内调用 uni.navigateTo
    static showCommodityAttributePage() {
        uni.navigateTo({ url: '/pages/basicfunctions/commodityAttributesPage' });
    }

    static showMeasurementUnitPage() {
        uni.navigateTo({ url: '/pages/basicfunctions/measurementUnitListPage' });
    }

    static showCommodityKindPage() {
        uni.navigateTo({ url: '/pages/basicfunctions/commodityCategoryListPage' });
    }

    static showCommodityMgrPage() {
        uni.navigateTo({ url: '/pages/v2views/commodity/commodityMgtPage' });
    }

    static showCustomerMgrPage() {
        uni.navigateTo({ url: '/pages/partners/customerMgrPage' });
    }

    static showSupplierMgrPage() {
        uni.navigateTo({ url: '/pages/partners/supplierMgrPage' });
    }

    static showWarehouseMgrPage() {
        uni.navigateTo({ url: '/pages/inventory/warehouseMgrPage' });
    }

    static showStoreMgrPage() {
        uni.navigateTo({ url: '/pages/store/storeMgr' });
    }

    static showInventoryBtachInMgrPage() {
        // inOutType=1 入库
        uni.navigateTo({ url: '/pages/inventory/inventoryBatchMgrPage?inOutType=1' });
    }

    static showInventoryBtachOutMgrPage() {
        // inOutType=0 出库
        uni.navigateTo({ url: '/pages/inventory/inventoryBatchMgrPage?inOutType=0' });
    }

    static showInventoryCommodityInOutRecordPage() {
        uni.navigateTo({ url: '/pages/inventory/inventoryCommodityInOutRecord' });
    }

    static showInventoryTypesPage() {
        uni.navigateTo({ url: '/pages/inventory/inventoryTypes' });
    }

    static showSubCommodityInventorySumPage() {
        uni.navigateTo({ url: '/pages/inventory/subCommodityInventorySum' });
    }

    // 普通销售单详情页面
    static showSalesDetailPage(router, params) {
        if (Definition.isWeb) {
            router.push({
                path: '/sales/sales/order',
                query: params ?? {}
            })
        } else {

        }

    }

    // 金属销售单详情页面
    static showMetalSalesDetailPage(router, params) { 
        if (Definition.isWeb) {
            router.push({
                path: '/business/metalSaleOrder',
                query: params ?? {}
            })
        } else {

        }
    }

    // 显示收款单详情页面
    static showReceiptOrderDetailPage(router, params) {
        if (Definition.isWeb) {
            router.push({
                path: '/fundorder/receiptorder',
                query: params ?? {}
            })
        } else {

        }
    }

        // 金属销售单详情页面
    static showMetalPurchaseDetailPage(router, params) { 
        if (Definition.isWeb) {
            router.push({
                path: '/business/metalOrder',
                query: params ?? {}
            })
        } else {

        }
    }

    // 显示收款单详情页面
    static showPaymentOrderDetailPage(router, params) {
        if (Definition.isWeb) {
            router.push({
                path: '/fundorder/paymentorder',
                query: params ?? {}
            })
        } else {

        }
    }

        // 显示应付单单详情页面
    static showPayableOrderDetailPage(router, params) {
        if (Definition.isWeb) {
            router.push({
                path: '/fundorder/pendingPaymentOrder',
                query: params ?? {}
            })
        } else {

        }
    }

    // 显示应收单详情页面
    static showReceivableOrderDetailPage(router, params) {
        if (Definition.isWeb) {
            router.push({
                path: '/fundorder/pendingReceiptOrder',
                query: params ?? {}
            })
        } else {

        }
    }

    // 显示贵金属加工单详情页面
    static showMetalRefiningContractDetailPage(router, params) {
        if (Definition.isWeb) {
            router.push({
                 path: '/business/refiningOrder',
                 query: params ?? {}
            })
        } else {

        }
    }

    // 显示商品详情
    static showCommodityDetailPage(router, params) {
        if (Definition.isWeb) {
            router.push({
                path: '/commodityMgt/commodity',
                query: params ?? {}
            })
        } else {

        }
    }
    // 显示角色详情
    static showRoleDetailPage(router, params) {
        console.log('showRoleDetailPage', params);
        if (Definition.isWeb) {
            router.push({
                path: '/org/roleDetail',
                query: params ?? {}
            })
        } else {

        }
    }

    // 显示角色详情
    static showEmployeeDetailPage(router, params) {
        console.log('showEmployeeDetailPage', params);
        if (Definition.isWeb) {
            router.push({
                path: '/org/employeeDetail',
                query: params ?? {}
            })
        } else {
        }
    }

        // 显示往来交易
    static showCustomerTransitionExcelPage(router, params) {
        console.log('showCustomerTransitionExcelPage', params);
        if (Definition.isWeb) {
            router.push({
                path: '/transactions/mtransactions',
                query: params ?? {}
            })
        } else {
        }
    }

    // 显示组织对象页面
    // type TargetObjectType
    // curTargetObj  TargetObject
    // filter TargetObjectFilter
    static showTargetObjectMgrPage(
        { type = null, curTargetObj = null, filter = null } = {}) {
        const uiAction = new BasicUiAction();
        return uiAction.showTargetObjectMgrPage({
            type: type,
            curTargetObj: curTargetObj, filter: filter
        } = {});
    }

    // 显示入库类型页面
    // inOutType InventoryInOutType
    static showInventoryInTypePage(inOutType) {
        const uiAction = new InventoryUiAction();
        return uiAction.showInventoryTypePage(inOutType);
    }

    /// 显示仓库选择页面
    /**
     * 
      WareHouse? excludeWareHouse,
      WareHouseFilter? filter,

      /// 当前选择仓库
      WareHouse? curWareHouse
     */
    static showWarehouseMgrPage({
        selectionMode = false,
        selectLockMode = false,
        excludeWareHouse = null,
        filter = null,
        curWareHouse = null
    } = {}) {
        const uiAction = new InventoryUiAction();
        return uiAction.showWarehouseMgrPage({
            selectionMode,
            selectLockMode,
            excludeWareHouse,
            filter,
            curWareHouse
        });
    }

}